<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Home extends CI_Controller {

	/**
	 * Index Page for this controller.
	 *
	 * Maps to the following URL
	 * 		http://example.com/index.php/welcome
	 *	- or -  
	 * 		http://example.com/index.php/welcome/index
	 *	- or -
	 * Since this controller is set as the default controller in 
	 * config/routes.php, it's displayed at http://example.com/
	 *
	 * So any other public methods not prefixed with an underscore will
	 * map to /index.php/welcome/<method_name>
	 * @see http://codeigniter.com/user_guide/general/urls.html
	 */
	public function index()
	{
		if($this->input->post())
		{
			$this->load->library('meta_libs/upload_lib');
			$this->upload_lib->upload();
			exit;
		}
		$str = file_get_contents('php://input');
		$str_details = json_decode(($str));
		//var_dump($str_details);die;
 		$type=@$str_details->type;
 		$data=@$str_details->data;
 		$function_name= @$str_details->context;
		//var_dump($str_details);
		//echo "fff";die;
		if(isset($type) && isset($data) && isset($function_name))
		{
			self::route($type, $function_name, $data);
		}
		else
		{
			//echo "Access denied!";
			//print_r($_FILES);
			$this->load->library('meta_libs/upload_lib');
			//echo "came";exit;
			$this->upload_lib->upload();

		}
	}
	
	function route($class_name,$function_name,$data,$version="")
	{  // $this->output->enable_profiler(TRUE);
		$meta_actual_lib=$class_name.'_lib';
		$method_name=$function_name;
		try
		{
			$this->load->library("meta_libs/".$meta_actual_lib);
			
			// call the appropriate function
			$this->contents=$this->$meta_actual_lib->$function_name($data);
		}
		catch(Exception $e)
		{
			echo "This object not found".$e;
			$error=1;
			$msg=$e;
		}
	 
	
	// $this->oauth_mobile_lib->log_analytics($arr);
	}
	
	function test(){
		$this->load->library('meta_libs/merchant_lib');
		//$this->load->library('photo/album');
		$this->merchant_lib->get_merchant_billboard_images('aa');
	}
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */